package com.smg.community.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javacommon.base.BaseRestSpringController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.jpush.api.ErrorCodeEnum;
import cn.jpush.api.MessageResult;

import com.google.gson.Gson;
import com.smg.community.model.SmgGroup;
import com.smg.community.model.SmgMember;
import com.smg.community.model.SmgMemberBehavior;
import com.smg.community.model.SmgTopic;
import com.smg.community.model.TalkHistory;
import com.smg.community.service.SmgTalkHistoryManager;
import com.smg.community.service.TalkService;
import com.smg.community.util.HtmlToText;
import com.smg.community.vo.query.SmgGroupQuery;
import com.smg.community.vo.query.SmgTopicQuery;

@Controller
@RequestMapping("/interface")
public class InterfaceController extends BaseRestSpringController<SmgMember, Integer>{
	
	
	

	
	@RequestMapping({"/gettaglist"})
	@ResponseBody
	public List<Map> getTagList(){
		SmgGroupQuery query = new SmgGroupQuery();
		query.setCityNo(21);
		query.setLimit(7);
		List<SmgGroup> smgGroupList = smgGroupManager.getByQuery(query);
		List<Map> list = new ArrayList<Map>();
		for (SmgGroup group:smgGroupList){
			Map hashMap = new HashMap();
			hashMap.put("tagName",group.getGroupName());
			hashMap.put("tagId",group.getGroupId());
			list.add(hashMap);
		}
		return list;
	}

	

	@RequestMapping({"/gettopiclistbytagid"})
	@ResponseBody
	public List<Map> getTopicListbyTagid(@RequestParam String tagId){
		SmgTopicQuery query = new SmgTopicQuery();
		query.setCityNo(21);
		query.setLimit(4);
		List<SmgTopic> smgTopicList = smgTopicManager.getFourHotTopicList(21);
		List<Map> list = new ArrayList<Map>();
		for (SmgTopic topic:smgTopicList){
			Map hashMap = new HashMap();
			hashMap.put("title",topic.getTopicTitleAfterFilter());
			hashMap.put("desc",HtmlToText.getPlainText(topic.getTopicContAfterFilter()));
			hashMap.put("picture",topic.getPicview());
			hashMap.put("createDate",topic.getCreateDateString());
			hashMap.put("praiseCount", topic.getPraiseCount());
			hashMap.put("replyCount", topic.getReplyCount());
			list.add(hashMap);
		}
		return list;
	}
	
	

	
	@RequestMapping({"/getuserlist"})
	@ResponseBody
	public List<Map> getUserList(){
		List<SmgMemberBehavior> behaviorList = smgMemberBehaviorManager.getJoinActivityBehavior();
		List<Map> list = new ArrayList<Map>();
		for (SmgMemberBehavior behavior:behaviorList){
			Map hashMap = new HashMap();    
			hashMap.put("cont",behavior.getCont());
			hashMap.put("memberId",behavior.getMemberId());
			hashMap.put("headImage",behavior.getHeadImage());
			hashMap.put("url","http://new.365take.com/"+behavior.getUrl());
			list.add(hashMap);
		}
		return list;
	}


}
